-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #363 - Multiple Configuration Profiles. #399
Conversation
@famod If you want to have a look :) |
Thanks! Will take me some time but I'll check it out. |
My recommendation is to checkout this PR, build SR Config and then update the SR Config dependency in Quarkus. |
@@ -27,10 +30,11 @@ | |||
} | |||
}; | |||
|
|||
private final String profile; | |||
private final String[] profiles; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to be in a list. In this way, if someone specifies conflicting config profiles such as test, prod. With the list, you can specify the order say the first one takes precedence. If they define the same properties e.g.
%test.name=Bob
%prod.name=Nick
At least, you can ensure the %test.name takes precedence over %prod.name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the array as well. In fact, priority is set with the first profile in the list and profile values are read in order. If one is found, that is the one returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are all ordered for sure. I just thought List is obvious. I think it is best to document which value is to be used.
FWIW, the following test fails on Windows:
|
Hm, strange. Seems like a regression?
PS: Version of Quarkus changed from 1.8.1.Final to 999-SNAPSHOT (depends on sr-config 1.9.1-SNAPSHOT). Same happens when running: In Quarkus dev mode this seems to be working, though! |
Strange. I'll have a look.
This is how I've implemented it, but we can turn it around. |
cb64f94
to
487ebf4
Compare
In case the latest push was supposed to fix the regression in the Quarkus quickstart: it does not fix it. |
487ebf4
to
532d103
Compare
No, it was just to update with latest master. This last push should fix the issue. Actually the issue has been there since we implemented line number info in properties file. It was not working on Windows. |
Also, I tried out with the getting started project and it seems to work as expected. Can you confirm? |
This is with Quarkus Diff in Quarkus: diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index 718130f58c..ccbd66a560 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -34,7 +34,7 @@
<microprofile-reactive-streams-operators.version>1.0.1</microprofile-reactive-streams-operators.version>
<microprofile-rest-client.version>1.4.1</microprofile-rest-client.version>
<smallrye-common.version>1.4.0</smallrye-common.version>
- <smallrye-config.version>1.9.0</smallrye-config.version>
+ <smallrye-config.version>1.9.1-SNAPSHOT</smallrye-config.version>
<smallrye-health.version>2.2.3</smallrye-health.version>
<smallrye-metrics.version>2.4.3</smallrye-metrics.version>
<smallrye-open-api.version>2.0.9</smallrye-open-api.version> |
Ok, let me have another look. |
Ok, I've tried this setup:
Update Quarkus BOM. I'm using https://github.com/quarkusio/quarkus/commits/47d4aa59e3770a94f56ed8f8d2189b5869b104e3 diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index a6d70ee780..5b41f83564 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -34,7 +34,7 @@
<microprofile-reactive-streams-operators.version>1.0.1</microprofile-reactive-streams-operators.version>
<microprofile-rest-client.version>1.4.1</microprofile-rest-client.version>
<smallrye-common.version>1.4.0</smallrye-common.version>
- <smallrye-config.version>1.9.0</smallrye-config.version>
+ <smallrye-config.version>1.9.1-SNAPSHOT</smallrye-config.version>
<smallrye-health.version>2.2.3</smallrye-health.version>
<smallrye-metrics.version>2.4.3</smallrye-metrics.version>
<smallrye-open-api.version>2.0.9</smallrye-open-api.version>
Update Quickstart project: diff --git a/getting-started/pom.xml b/getting-started/pom.xml
index 293e4b65..d24c6504 100644
--- a/getting-started/pom.xml
+++ b/getting-started/pom.xml
@@ -10,7 +10,7 @@
<quarkus-plugin.version>1.8.1.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
- <quarkus.platform.version>1.8.1.Final</quarkus.platform.version>
+ <quarkus.platform.version>999-SNAPSHOT</quarkus.platform.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/getting-started/src/main/resources/application.properties b/getting-started/src/main/resources/application.properties
index dc78bc19..37422ed4 100644
--- a/getting-started/src/main/resources/application.properties
+++ b/getting-started/src/main/resources/application.properties
@@ -1,2 +1,4 @@
# Quarkus Configuration file
# key = value
+quarkus.banner.enabled=true
+%foo.quarkus.banner.enabled=false
+%bar.quarkus.banner.enabled=true
Resultsmvn quarkus:devmvn quarkus:dev
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.acme:getting-started >----------------------
[INFO] Building getting-started 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:1.8.1.Final:dev (default-cli) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/radcortez/Code/open-source/quarkus-quickstarts/getting-started/target/classes
Listening for transport dt_socket at address: 5005
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
Powered by Quarkus 999-SNAPSHOT
2020-10-01 13:36:37,563 INFO [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 0.903s. Listening on: http://0.0.0.0:8080
2020-10-01 13:36:37,566 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2020-10-01 13:36:37,566 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy] mvn quarkus:dev -Dquarkus.profile=foomvn quarkus:dev -Dquarkus.profile=foo
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.acme:getting-started >----------------------
[INFO] Building getting-started 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:1.8.1.Final:dev (default-cli) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Nothing to compile - all classes are up to date
Listening for transport dt_socket at address: 5005
2020-10-01 13:37:40,964 INFO [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 0.855s. Listening on: http://0.0.0.0:8080
2020-10-01 13:37:40,980 INFO [io.quarkus] (Quarkus Main Thread) Profile foo activated. Live Coding activated.
2020-10-01 13:37:40,980 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy] mvn quarkus:dev -Dquarkus.profile=bar,foomvn quarkus:dev -Dquarkus.profile=bar,foo
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.acme:getting-started >----------------------
[INFO] Building getting-started 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:1.8.1.Final:dev (default-cli) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Nothing to compile - all classes are up to date
Listening for transport dt_socket at address: 5005
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
Powered by Quarkus 999-SNAPSHOT
2020-10-01 13:39:06,766 INFO [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 0.831s. Listening on: http://0.0.0.0:8080
2020-10-01 13:39:06,785 INFO [io.quarkus] (Quarkus Main Thread) Profile bar,foo activated. Live Coding activated.
2020-10-01 13:39:06,785 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy] mvn quarkus:dev -Dquarkus.profile=foo,barmvn quarkus:dev -Dquarkus.profile=foo,bar
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.acme:getting-started >----------------------
[INFO] Building getting-started 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:1.8.1.Final:dev (default-cli) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Nothing to compile - all classes are up to date
Listening for transport dt_socket at address: 5005
2020-10-01 13:40:00,921 INFO [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 0.848s. Listening on: http://0.0.0.0:8080
2020-10-01 13:40:00,940 INFO [io.quarkus] (Quarkus Main Thread) Profile foo,bar activated. Live Coding activated.
2020-10-01 13:40:00,940 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy] java -jar -Dquarkus.profile=bar,foo target/getting-started-1.0-SNAPSHOT-runner.jarjava -jar -Dquarkus.profile=bar,foo target/getting-started-1.0-SNAPSHOT-runner.jar
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2020-10-01 13:40:47,320 INFO [io.quarkus] (main) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 0.584s. Listening on: http://0.0.0.0:8080
2020-10-01 13:40:47,340 INFO [io.quarkus] (main) Profile bar,foo activated.
2020-10-01 13:40:47,341 INFO [io.quarkus] (main) Installed features: [cdi, resteasy] java -jar -Dquarkus.profile=foo,bar target/getting-started-1.0-SNAPSHOT-runner.jarjava -jar -Dquarkus.profile=foo,bar target/getting-started-1.0-SNAPSHOT-runner.jar
2020-10-01 13:41:22,277 INFO [io.quarkus] (main) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 0.672s. Listening on: http://0.0.0.0:8080
2020-10-01 13:41:22,302 INFO [io.quarkus] (main) Profile foo,bar activated.
2020-10-01 13:41:22,302 INFO [io.quarkus] (main) Installed features: [cdi, resteasy] |
And this sample showcases multiple values profiles as well: radcortez/quarkus-playground@7d769ba java -jar -Dquarkus.profile=prod,common,new target/number-api-runner.jar
curl http://localhost:8081/numbers/generate
MV-ABC2200277113
java -jar -Dquarkus.profile=prod,common target/number-api-runner.jar
curl http://localhost:8081/numbers/generate
BK-ABC9768326113 |
I might be missing some scenario. Please let me know it this is working for you or if I'm missing anything. Thanks! |
Thanks for all these details! I'll re-check in the next few days. |
You should do it anyway, because we may have different states in our repo, so to be on the safe side might as well do it. |
Hm, Have you tried my Quarkus-Quickstart branch quarkusio/quarkus-quickstarts@master...famod:multiple-profiles ? Could this be related to Windows? |
The feature, right? But not the build.
I've used my own. I'll try yours now.
I don't see a reason for it. There was indeed a Windows issue, related with another feature that I've fixed here: 13efd6d. But it doesn't impact this one. |
532d103
to
5f5e157
Compare
@famod I've tried with your branch, and it seems fine to me as well: mvn quarkus:dev -Dquarkus.profile=foo,bar
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.acme:getting-started >----------------------
[INFO] Building getting-started 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:999-SNAPSHOT:dev (default-cli) @ getting-started ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Nothing to compile - all classes are up to date
Listening for transport dt_socket at address: 5005
2020-10-02 14:29:36,781 INFO [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 0.928s. Listening on: http://0.0.0.0:12345
2020-10-02 14:29:36,803 INFO [io.quarkus] (Quarkus Main Thread) Profile foo,bar activated. Live Coding activated.
2020-10-02 14:29:36,803 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy] How are you passing the profile to activate? With |
It already fails without activating any special profile. |
But did you try running that command to activate the profiles? The failure you are having is this one? One or more configuration errors has prevented the application from starting. The errors are:
Configuration key "quarkus.banner.enabled" is required, but its value is empty/missing: SRCFG00014: Property quarkus.banner.enabled not found |
I am getting:
Btw, after your recent push Quarkus build fails with:
So unfortunately I cannot properly test the quickstart anymore... |
5f5e157
to
d310df3
Compare
@radcortez you pushed an update, so does it make sense to try another test run? |
Yes. The PR already has the updates to SR Config 1.9.1. which requires my Quarkus 1.9.1 Config support here: https://github.com/radcortez/quarkus/tree/config-1.9.1 |
Ok. 1.9.1 has also been merged into Quarkus already: quarkusio/quarkus#12501 |
runner.jar now works as expected but I still get these strange test failures:
The test passes when I add properties without any profile prefix:
Btw, I only have one |
Let me have a look. |
Might be something Quarkus specific after all. |
Yes, I'm suspecting that. |
d310df3
to
2aaf664
Compare
Ok, I've made a small fix that should resolve that issue. I've also reversed the order of the profiles lookup, meaning that profiles defined later in the string will have higher priority. |
The test in But shouldn't the following execution display the banner?
Given:
? |
2aaf664
to
319d686
Compare
Yes, I've messed up somewhere :) Should be fixed now. |
Confirmed! |
Great! Merging this then :) |
Thank you for all your help :) |
No description provided.